home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / pointers.swg / 0043_Returns segment and offset of hex.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1997-03-04  |  1.2 KB  |  53 lines

  1. {
  2.  
  3.    Pointers functions: returns the segment and the offset in hexadecimal
  4.    value (in a string variable)
  5.  
  6.  
  7.                ╔════════════════════════════════════════╗
  8.                ║                                        ║░
  9.                ║          AVONTURE CHRISTOPHE           ║░
  10.                ║              AVC SOFTWARE              ║░
  11.                ║     BOULEVARD EDMOND MACHTENS 157/53   ║░
  12.                ║           B-1080 BRUXELLES             ║░
  13.                ║              BELGIQUE                  ║░
  14.                ║                                        ║░
  15.                ╚════════════════════════════════════════╝░
  16.                ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  17.  
  18. }
  19.  
  20. Function Segment (Chiffre : Pointer)  : String;
  21.  
  22. Type TWordRec = Record
  23.        Lo, Hi : Word;
  24.     End;
  25.  
  26. Begin
  27.  
  28.      Segment := Word2Hex(TWordRec(Chiffre).Hi);
  29.  
  30. End;
  31.  
  32. Function Offset (Chiffre : Pointer)  : String;
  33.  
  34. Type TWordRec = Record
  35.        Lo, Hi : Word;
  36.     End;
  37.  
  38. Begin
  39.  
  40.      Offset := Word2Hex(TWordRec(Chiffre).Lo);
  41.  
  42. End;
  43.  
  44. Var
  45.    p : Pointer;
  46.  
  47. Begin
  48.  
  49.    p := Ptr($B800:$0000);
  50.  
  51.    Writeln (Segment(p),":",Offset(p));
  52.  
  53. End.